/// 错误显示组件
/// 
/// 通用的错误状态显示组件
/// 显示错误信息和可选的重试按钮
/// 
/// 作者: Fluttert Team
/// 日期: 2024

import 'package:flutter/material.dart';

/// 自定义错误组件
/// 
/// 用于在发生错误时显示错误信息
class CustomErrorWidget extends StatelessWidget {
  /// 错误消息
  final String message;
  
  /// 重试回调（可选）
  final VoidCallback? onRetry;

  const CustomErrorWidget({
    super.key,
    required this.message,
    this.onRetry,
  });

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Icon(
            Icons.error_outline,
            size: 64,
            color: Theme.of(context).colorScheme.error,
          ),
          const SizedBox(height: 16),
          Text(
            message,
            style: Theme.of(context).textTheme.bodyLarge,
            textAlign: TextAlign.center,
          ),
          if (onRetry != null) ...[
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: onRetry,
              child: const Text('重试'),
            ),
          ],
        ],
      ),
    );
  }
}

